package com.tan.lbs.util;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.widget.ImageView;

public class ResourceReader {

	public static Bitmap readImage(Context context, String mediaID) {
		Bitmap image = null;
		AssetManager am = context.getResources().getAssets();
		try {
			InputStream is = new BufferedInputStream(am.open(mediaID + ".png"));
			image = BitmapFactory.decodeStream(is);
			is.close();
			return image;
		} catch (IOException e) {
		}
		
		try {
			InputStream is = new BufferedInputStream(am.open(mediaID + ".gif"));
			image = BitmapFactory.decodeStream(is);
			is.close();
			return image;
		} catch (IOException e) {
		}
		
		try {
			InputStream is = new BufferedInputStream(am.open(mediaID + ".jpg"));
			image = BitmapFactory.decodeStream(is);
			is.close();
			return image;
		} catch (IOException e) {
		}
		
		return null;

	}
}
